package com.xuan.error;

public class test2 {
    public static void main(String[] args) {
        int a=1;
        int b=0;

//        ctrl alt+t,自动生成代码块包裹起来
        try {

            System.out.println(a/b);
        } catch (Exception e) {
//            throw new RuntimeException(e);//
            e.printStackTrace();//打印错误的栈信息
        } finally {
            System.out.println("捕获");
        }
    }
    public void test(int a,int b){
        if (b==0) {//主动抛出异常throw throws
            throw new ArithmeticException();//主动抛出异常

        }
    }
}
